#include<bits/stdc++.h>
#define y1 __________
#define y2 ______________________
using namespace std;
const int N = 2e3+5;
int n,m,q,mx[] = {1,-1,0,0},my[] = {0,0,1,-1},x1,y1,x2,y2,ans;
char a[N][N],b[N][N];
void bfs(int s,int t)
{
	ans++;
	queue<int> x,y;
	x.push(s),y.push(t);
	while(!x.empty())
	{
		int ux = x.front(),uy = y.front();x.pop(),y.pop();
		b[ux][uy] = '0';
		for(int i = 0;i<4;i++)
		{
			int vx = ux+mx[i],vy = uy+my[i];
			if(b[vx][vy]=='1'&&vx>=x1&&vx<=x2&&vy>=y1&&vy<=y2) x.push(vx),y.push(vy);
		}
	}
}
signed main()
{
	freopen("unicom.in","r",stdin);
	freopen("unicom.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>q;
	for(int i = 1;i<=n;i++)
		for(int j = 1;j<=m;j++)
			cin>>a[i][j];
	while(q--)
	{
		ans = 0;
		memcpy(b,a,sizeof a);
		cin>>x1>>y1>>x2>>y2;
		for(int i = x1;i<=x2;i++)
			for(int j = y1;j<=y2;j++)
				if(b[i][j]=='1')
					bfs(i,j);
		cout<<ans<<'\n';
	}
	return 0;
}

